﻿/*<summary>
Created By : Swati
Created On : 10/15/2008
Class Name : PatientDetails_DataLoader
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/

using System.Xml;
using System.Data;
using System;
using Utils;
using System.Data.SqlClient;

namespace RegistrationController
{
    public class PatientDetails_DataLoader
    {
        public bool Get_Package_Details(string CRN, PatientRegistration objPatient)
        {
            ezUtilsAdapter DBL = new ezUtilsAdapter();
            DataSet ds = new DataSet();
            long RetVal = -1;

            try
            {
                ds = DBL.RunSPReturnDataSet("SP_GetPatientPackage", "TR",
                        new SqlParameter("@biCRN", CRN));
                
                if (ds != null &&
                    ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    if (objPatient != null)
                    {
                        objPatient.PackageName = Convert.ToString(dr["PackageName"]);
                    }
                }
                if (RetVal == -1) { return false; } else { return true; }
            }
            catch (SqlException ex)
            {
                return false;
            }
            finally
            {
                DBL.Dispose();
            }
        }

        public DataSet Get_Consultant_Visits(string CRN)
        {
            ezUtilsAdapter DBL = new ezUtilsAdapter();
            DataSet ds = null;

            try
            {
                ds = DBL.RunSPReturnDataSet("SP_GetPatientConsultantVisit", "TR",
                        new SqlParameter("@biCRN", CRN));

                return ds;
            }
            catch (SqlException ex)
            {
                string errorMessage = String.Format(
                    "An Error Occurred While Loading the Consultant Visits from the DB. Message: {0}", ex.Message);
                return ds;
            }
            finally
            {
                DBL.Dispose();
                if (ds != null)
                {
                    ds.Dispose();
                }
            }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }
    }
}